
<?php use_helper('Object') ?>

<?php echo form_tag('structure/fourthupdate', Array('id' => 'frmstructure', 'name' => 'frmstructure', 'method' => 'post', 'enctype' => 'multipart/form-data')) ?>
<?php echo object_input_hidden_tag($tbl_structure, 'getFId') ?>
<?php echo input_hidden_tag('form_action') ?>

<script type="text/javascript">
function formchecking(action) {
	var isOK = 'Yes';
	if (document.getElementById('f_name').value == '') {
		alert('Please enter structure name!');
		return false;
	}else if(document.frmstructure.f_structure.value == '0'){
		isOK = 'No';
		alert('Please select structure');
	}
	
	document.getElementById('form_action').value = action;
	
	if(isOK == 'Yes')
		document.getElementById('frmstructure').submit();
}

function getStructure(){
	var x=document.getElementById("f_structure");

	var i;
	for (i = x.length - 1; i>=1; i--) {
		x.remove(i);
	}
	
	arr_structure = document.frmstructure.structure.options[document.frmstructure.structure.selectedIndex].value;
	
	if(arr_structure!='0'){
		arr_second = arr_structure.split(":");		
	
		for(i = 0; i < arr_second.length; i++){
			arr_info = arr_second[i].split(";;");
			
			var option=document.createElement("option");
			option.text=arr_info[0];
			option.value=arr_info[1];
			
			try
			{
			  x.add(option,x.options[null]);
			}
			catch (e)
			{
			  x.add(option,null);
			}			
		}
	}			
}

function getStructure2(){
	var x=document.getElementById("f_structure2");

	var i;
	for (i = x.length - 1; i>=1; i--) {
		x.remove(i);
	}
	
	arr_structure = document.frmstructure.f_structure.options[document.frmstructure.f_structure.selectedIndex].value;
	
	if(arr_structure!='0'){
		arr_third = arr_structure.split(";");
	
		for(i = 0; i < arr_third.length; i++){
			arr_info = arr_third[i].split("+");
			
			var option=document.createElement("option");
			option.text=arr_info[1];
			option.value=arr_info[0];
			
			try
			{
			  x.add(option,x.options[null]);
			}
			catch (e)
			{
			  x.add(option,null);
			}			
		}
	}			
}
</script>

<script type="text/javascript" src="/js/tiny_mce/tiny_mce.js" ></script >
<script type="text/javascript">
tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,imagemanager",

        //plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,imagemanager,filemanager",
                
        // Theme options - button# indicated the row# only
        theme_advanced_buttons1 : "undo,redo,|,code,fullscreen,|,image,insertimage,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "forecolor,backcolor,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,pagebreak,|,charmap,emotions,iespell,hr,advhr,|,tablecontrols",
		theme_advanced_buttons3 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,cleanup,help,|,insertdate,inserttime,|,removeformat,visualaid,|,sub,sup,|,ltr,rtl",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,
        
        // Example content CSS (should be your site CSS)
		content_css : "/css/main.css"
});
</script>

<table width='100%' align=center>
	<tr>
    	<td valign="middle" align="center">
        <form name="myForm">        	
   	    <table>
            	<tr>
                	<td align="left" colspan="3" class="popTitle">
                	<?php if ($tbl_structure->getFId() == NULL) echo "Create New Structure 4"; else echo "Edit Structure 4"; ?>
                	</td>
                </tr>
                <tr>
				  	<td align="left">Structure</td>
                    <td align="left">:</td>
                    <td align="left">
				        <select name="structure" id="structure" onChange="getStructure()">
						<option value="0">Please select</option>
						<?php
						foreach($structure_arr as $structure){
							$t = split("::",$structure);
							
							if($t[0]===$old_first_structure)
								echo "<option value='".str_replace("'s","",$t[1])."' selected>".$t[0]."</option>";
							else
								echo "<option value='".str_replace("'s","",$t[1])."'>".$t[0]."</option>";
						}
						?>
						</select>
						<select name="f_structure" id="f_structure"  onChange="getStructure2()">
						<option value="0">Please select</option>
						<?php
						foreach ($sstructure as $structure){
							if($structure->getFName()==$old_second_structure){
								echo "<option value='".$structure->getFId()."' selected>".$structure->getFName()."</option>";
							}else{
								echo "<option value='".$structure->getFId()."'>".$structure->getFName()."</option>";
							}
						}
						?>
						</select>
						<select name="f_structure2" id="f_structure2">
						<option value="0">Please select</option>
						<?php
						foreach ($ssstructure as $structure){
							if($structure->getFName()==$old_third_structure){
								echo "<option value='".$structure->getFId()."' selected>".$structure->getFName()."</option>";
							}else{
								echo "<option value='".$structure->getFId()."'>".$structure->getFName()."</option>";
							}
						}
						?>
						</select>
				  	</td>
				</tr>
                <tr>
                	<td align="left">Name</td>
                    <td align="left">:</td>
                    <td align="left">
                    <?php echo object_input_tag($tbl_structure, 'getFName', array ('size' => 50)) ?>
                    </td>
                </tr>                
                <tr>
                	<td align="left">Page Title</td>
                    <td align="left">:</td>
                    <td align="left">
                    <?php echo object_input_tag($tbl_structure, 'getFTitle', array ('size' => 50)) ?>
                    </td>
                </tr>
                <tr>
                	<td align="left">External Link</td>
                    <td align="left">:</td>
                    <td align="left">
                    <select name="external_link" id="external_link">
						<option value="0" <?php if($tbl_structure->getExternalLink()=='0') echo 'selected' ?>>No</option>
						<option value="1" <?php if($tbl_structure->getExternalLink()=='1') echo 'selected' ?>>Yes (New Browser)</option>
						<option value="2" <?php if($tbl_structure->getExternalLink()=='2') echo 'selected' ?>>Yes (Current Browser)</option>
                    </td>
                </tr>
                <tr>
                	<td align="left">Favourites Link</td>
                    <td align="left">:</td>
                    <td align="left">
                    <?php echo object_input_tag($tbl_structure, 'getFLink', array ('size' => 50)) ?>
                    </td>
                </tr>                
                <tr>
                	<td align="left">Display Method</td>
                    <td align="left">:</td>
                    <td align="left">
                    <select name="children_link_type" id="children_link_type">
						<option value="list" <?php if($tbl_structure->getChildrenLinkType()=='list') echo 'selected' ?>>List</option>
						<option value="combo" <?php if($tbl_structure->getChildrenLinkType()=='combo') echo 'selected' ?>>Combo box</option>
						<option value="link" <?php if($tbl_structure->getChildrenLinkType()=='link') echo 'selected' ?>>HTML Link</option>
                    </td>
                </tr>
                <tr>
                	<td align="left">Sequence Number</td>
                    <td align="left">:</td>
                    <td align="left">
                    <?php echo object_input_tag($tbl_structure, 'getFSeqNo', array ('size' => 10)) ?>
                    </td>
                </tr>
                <tr>
                	<td align="left" valign="top">Background Image</td>
                    <td align="left" valign="top">:</td>
                    <td align="left">
                    <input name="upload_file1" id="upload_file1" type="file" onkeypress="return false" />
                    <br><input type="checkbox" id="f_image" name="f_image" value="1" />Remove Live Image
					<br><input type="checkbox" id="f_image_draft" name="f_image_draft" value="1" />Remove Draft Image
                    </td>
                </tr>
                <tr>
                	<td align="left">Meta Keyword</td>
                    <td align="left">:</td>
                    <td align="left">
                    <?php echo object_input_tag($tbl_structure, 'getFMetaKeyword', array ('size' => 50)) ?>
                    </td>
                </tr>
                <tr>
                	<td align="left">Meta Description</td>
                    <td align="left">:</td>
                    <td align="left">
                    <?php echo object_input_tag($tbl_structure, 'getFMetaDescription', array ('size' => 50)) ?>
                    </td>
                </tr>
                <tr>
                	<td align="left" valign="top">Source</td>
                    <td align="left" valign="top">:</td>
                    <td align="left">
                    <?php 
                    	if($tbl_structure->getFContentDraft()=="")
                    		echo '<textarea id="content" name="content" cols="50" rows="15" >'.$tbl_structure->getFContent().'</textarea>';
                    	else
                    		echo '<textarea id="content" name="content" cols="50" rows="15" >'.$tbl_structure->getFContentDraft().'</textarea>';
                    ?>
                    </td>
                </tr>
            </table>
            </form>
        </td>
    </tr>
    <tr>
    	<td valign="middle" align="center">
    		<button type="button" onClick="location.href='<?php echo url_for('/structure/list'); ?>'">Cancel</button>&nbsp;&nbsp;
    		<button type="button" onClick="return formchecking('0')">Save</button>&nbsp;&nbsp;
    		<?php 
			if($tbl_structure->getFContentDraft()<>"" || $tbl_structure->getFIconDraft()<>"" || $tbl_structure->getFImageDraft()<>""){	
	    			echo '<button type="button" onClick="return formchecking(\'1\')">Publish</button>';
			}
			?>
			<?php 
			if($tbl_structure->getFContent()<>"" || $tbl_structure->getFIcon()<>"" || $tbl_structure->getFImage()<>""){	
	    			echo '<button type="button" onClick="return formchecking(\'2\')">Unpublish</button>';
			}
			?>
    	</td>
    </tr>
</table>

</form>


